/* Display.hh -- Mostra as informações de jogo no terminal
 *
 * Copyright (C) 2008, Diogo F. S. Ramos <diogo.ramos@usp.br>
 * GEAR - Grupo de Estudos Avançados em Robótica
 * <http://www.sel.eesc.usp.br/gear>
 *
 * This file is part of GEARMedula.
 * 
 * GEARMedula is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 3 of the
 * License.
 * 
 * GEARMedula is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#ifndef DISPLAY_HH_
#define DISPLAY_HH_

#include <vector>

#include <pthread.h>
#include <ncurses.h>

#include "Thread.hh"
#include "Monitor.hh"

class Display: public Thread
{
    int enable_;
    pthread_mutex_t enable_mutex_;
    pthread_t display_thread_;

    /* Informações do mundo */
    std::vector<float> world_;
    int w_x0_pos_;
    int w_y0_pos_;
    int w_x_inc_;
    int world_nlines_;
    int world_startx_;

    /* Informações dos objetos em campo */
    std::vector<float> field_;
    int f_x0_pos_;
    int f_y0_pos_;
    int f_x_inc_;
    int field_nlines_;
    int field_startx_;

    /* windows */
    WINDOW * world_window_;
    WINDOW * field_window_;
    WINDOW * errinf_window_;

    /* monitor */
    Monitor * monitor_;

    /* Private Functions */
    void Run( void * ptr );
    void initNCurses();
    void endNCurses();
    void worldWindowInit();
    void fieldWindowInit();
    void errinfWindowInit();
    void worldWindowUpdate();
    void worldWindowSetPos( int x, int y, float data);
    void fieldWindowUpdate();
    void fieldWindowSetPos( int x, int y, float data);
    void errinfWindowUpdate();
public:
    Display();
    ~Display();
    void Init( Monitor * monitor );
};

#endif	/* DISPLAY_HH_ */
